home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / langguid / chap_06 / xmpl_01.sx next >
Encoding:
Text File  |  1996-05-21  |  791 b   |  40 lines  |  [TEXT/ttxt]

  1. --<<<
  2. -- Kaleida Labs, Inc.
  3. -- Field Guide to the ScriptX Language
  4. -- chapter 6, example 1
  5.  
  6. -- create a mudule to avoid naming conflicts
  7. module Scratch20 uses ScriptX end
  8. in module Scratch20
  9.  
  10. -- purple dragons
  11.  
  12. global dragon1, dragon2
  13.  
  14. class PurpleDragon ()
  15.     class vars numDragons : 0
  16.     instance methods
  17.         method moreDragons self -> (
  18.             (getClass self).numDragons := (getClass self).numDragons + 1
  19.         )
  20. end
  21.  
  22. dragon1 := new PurpleDragon
  23. dragon2 := new PurpleDragon
  24. PurpleDragon.numDragons -- the initial value
  25. moreDragons dragon1
  26. moreDragons dragon2
  27. PurpleDragon.numDragons -- find out new value
  28.  
  29.  
  30. -- luxury cars
  31. class LuxuryCar ()
  32.     class variables paneling:@oak
  33. end
  34.  
  35. class BargainLuxuryCar (LuxuryCar) end
  36. BargainLuxuryCar.paneling
  37.  
  38. LuxuryCar.paneling := @Teak
  39. BargainLuxuryCar.paneling
  40. -->>>